package com.zuowei.ycy.ui;

import android.content.Intent;

import com.and.yzy.frame.crop.CropHandler;
import com.and.yzy.frame.crop.CropHelper;
import com.zuowei.ycy.user.domain.ResultInfo;
import com.zuowei.ycy.user.util.AppJsonUtil;

import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;


/**
 * Created with Android Studio. User: ryan@xisue.com Date: 10/ic_01/14 Time: 10:58
 * AM Desc: BasePhotoCropActivity
 */
public abstract class BasePhotoCropActivity extends BaseToolbarAty implements
        CropHandler {

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        CropHelper.handleResult(this, requestCode, resultCode, data);
    }


    @Override
    public void onCancel() {
    //    showToast("取消");
    }

    @Override
    public void onFailed(String message) {
        showToast("失败:"+message);
    }

    @Override
    public void handleIntent(Intent intent, int requestCode) {
        startActivityForResult(intent, requestCode);
    }
    @Override
    protected void onDestroy() {
        CropHelper.clearCacheDir();
        super.onDestroy();
    }
    @Override
    public void onFailure(String result, Call<ResponseBody> call, Response<ResponseBody> response, int what) {
        ResultInfo resultInfo= AppJsonUtil.getResultInfo(result);

        showToast(resultInfo.getMessage());

        super.onFailure(result, call, response, what);
    }
}
